package com.ctvit.sjk.knowledge.app.pojo.vo;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.ctvit.sjk.knowledge.app.pojo.domain.TabAppAccessToken;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

/**
 * 应用访问令牌查询VO
 *
 * @author heyingcheng
 * @date 2025/03/28
 */
@Getter
@Setter
@ToString
public class AppAccessTokenGetVO {

    @JsonProperty("application_id")
    private String applicationId;
    @JsonProperty("access_token")
    private String accessToken;
    @JsonProperty("is_active")
    private Boolean isActive;
    @JsonProperty("access_num")
    private Integer accessNum;
    @JsonProperty("white_active")
    private Boolean whiteActive;
    @JsonProperty("white_list")
    private JSONArray whiteList;
    @JsonProperty("show_source")
    private Boolean showSource;
    private String language;

    public AppAccessTokenGetVO(TabAppAccessToken entity) {
        this.applicationId = entity.getAppId();
        this.accessToken = entity.getAccessToken();
        this.isActive = entity.getActiveFlag();
        this.accessNum = entity.getAccessNum();
        this.whiteActive = entity.getWhiteActive();
        this.whiteList = JSON.parseArray(StringUtils.defaultString(entity.getWhiteList(), "[]"));
        this.showSource = entity.getShowSource();
        this.language = entity.getLanguage();
    }

}
